package com.kejiguan.ui.presenter;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

/**
 * Created by apple on 16/3/31.
 */
public abstract class BaseFragmentPresenter {

    protected Application application;
    protected Context mContext;

    public void attach(Context context) {
        mContext = context;
        application= (Application) mContext.getApplicationContext();
    }

    /**
     * 在Fragment、Activity的onDestroy中调用.用于注销广播接收器等</br>
     */
    public void detach() {
        mContext = null;
    }

    protected boolean isActivityAlive() {
        if (mContext instanceof Activity) {
            Activity activity = (Activity) mContext;
            return !activity.isFinishing();
        }
        return false;
    }
}
